import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
/**
 * 这样写法分步加载代码
 * 1. 先把每个页面定义下来
 * 2. 添加到下面 router []
 * 3. 这是懒加载方式
 */

const Status = (resolve: any) => {
  require.ensure([], () => {
    resolve(require('@/components/wl_status.vue'))
  });
};

const Main = (resolve: any) => {
  require.ensure([], () => {
    resolve(require('@/views/main_page/main_page.vue'))
  });
};

const Login = (resolve: any) => {
  require.ensure([], () => {
    resolve(require('@/views/login/login.vue'))
  });
};


Vue.use(Router)

export default new Router({
  routes: [
    /** 添加每个页面 url */
    // {path: '/', redirect: '/login'},//定义的初始路由路径
    {
      path: '/',
      redirect: 'login',
    },
    {
      path: '/login',
      name: 'login',
      component: _import('login/login'),
    },
    {
      path: '/dashboard',
      name: 'dashboard',
      component: Main,
    },
    {
      path: '',
      component: _import('layout/layout'),
      meta: {
        title: 'base_manage',
        icon: 'home'
      },
      children: [
        {
          path: 'main',
          name: 'main',
          component: Main,
          meta: {
            title: 'main_page', icon: 'home', noCache: true
          }
        }]
    },
    {
      path: '',
      component: _import('layout/layout'),
      meta: {
        title: 'base_manage',
        icon: 'jcgl'
      },
      children: [
        {
          path: 'org',
          name: 'org',
          component: _import('org/org'),
          meta: { title: 'org', icon: 'jgzz', noCache: true }
        },
        {
          path: 'acc_manage',
          name: 'acc_manage',
          component: _import('acc_manage/acc_manage'),
          meta: { title: 'acc_manage', icon: 'jczh', noCache: true }
        },
        {
          path: 'member',
          name: 'member',
          component: _import('member/member'),
          meta: { title: 'member', icon: 'jcjs', noCache: true }
        },
        {
          path: 'web_manage',
          name: 'web_manage',
          component: _import('web_manage/web_manage'),
          meta: { title: 'web_manage', icon: 'wzgl', noCache: true }
        },
        {
          path: '/audit',
          component: _import('home/home'),
          meta: { title: 'audit', icon: 'jcsh' },
          children: [
            {
              path: 'audit_template',
              name: 'audit_template',
              component: _import('audit_template/audit_template'),
              meta: { title: 'audit_template', icon: 'jcsh', noCache: true },
            },
            {
              path: 'audit_manage',
              name: 'audit_manage',
              component: _import('audit_manage/audit_manage'),
              meta: { title: 'audit', icon: 'jcsh', noCache: true },
            },
          ]
        },
        {
          path: 'log',
          name: 'log',
          component: _import('log/log'),
          meta: { title: 'log', icon: 'rzgl', noCache: true }
        },
      ]
    },
    {
      path: '',
      component: _import('layout/layout'),
      meta: {
        title: 'base_manage',
        icon: 'wzfw'
      },
      children: [
        {
          path: 'web_visit',
          name: 'web_visit',
          component: _import('web_visit/web_visit'),
          meta: {
            title: 'web_visit', icon: 'wzfw', noCache: true
          }
        }]
    },
  ]
});

